package com.examiner.dao;

import com.examiner.bean.test.NewTestItem;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface NewTestItemDao extends JpaRepository<NewTestItem,Integer>, JpaSpecificationExecutor<NewTestItem> {

    @Query(value = "delete from new_test_item where ntuid=?1", nativeQuery = true)
    @Modifying(clearAutomatically = true)
    void deleteByNtuid(Integer id);

    @Query(value = "select * from new_test_item where ntuid=?1 and sid=?2", nativeQuery = true)
    List<NewTestItem> findByNtuidAndSid(Integer id, Integer testTypeId);
}
